package com.zj.osm.entity.greendao;

import android.os.Parcel;
import android.os.Parcelable;

import androidx.annotation.NonNull;

import org.greenrobot.greendao.DaoException;
import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.Index;
import org.greenrobot.greendao.annotation.JoinEntity;
import org.greenrobot.greendao.annotation.ToMany;

import java.util.ArrayList;
import java.util.List;
import com.zj.osm.entity.db.DaoSession;
import com.zj.osm.entity.db.PointDao;
import com.zj.osm.entity.db.LineDao;
import com.zj.osm.entity.db.EquipmentDao;
import com.zj.osm.entity.db.LayDao;

/**
 * 线类，和设备一对多，和点多对多，和项目多对一
 *
 * @author jiang zhu on 2019/10/24
 */
@Entity
public class Line implements Parcelable {
    @Id(autoincrement = true)
    private Long id;
    @Index(unique = true)
    private String lineId;
    //线的uuid
    private String cid;
    //开始点编号
    private String start_id;
    //结束点编号
    private String end_id;
    //项目ID
    private Long projectId;
    //线的名称
    private String name;

    //region 湖南
    //道路主次路
    private String roadPands;
    //道路位置
    private String roadAdress;
    //资源类型
    private String resType;
    //资源规格
    private String resSpec;
    //电缆支架规格（架长*间距*高度）
    private String dlzjSpec;
    //已经占用数量
    private String ardUseNumer;
    //电力孔数
    private String electriHoleNumer;
    //剩余数量
    private String remaNumber;
    //通道利用率
    private String roadUtili;
    //资源长度
    private String resLength;
    //备注
    private String note;
    //年
    private String srcYear;

    public String getSrcYear() {
        return srcYear;
    }

    public void setSrcYear(String srcYear) {
        this.srcYear = srcYear;
    }

    public String getRoadPands() {
        return roadPands;
    }

    public void setRoadPands(String roadPands) {
        this.roadPands = roadPands;
    }

    public String getRoadAdress() {
        return roadAdress;
    }

    public void setRoadAdress(String roadAdress) {
        this.roadAdress = roadAdress;
    }

    public String getResType() {
        return resType;
    }

    public void setResType(String resType) {
        this.resType = resType;
    }

    public String getResSpec() {
        return resSpec;
    }

    public void setResSpec(String resSpec) {
        this.resSpec = resSpec;
    }

    public String getArdUseNumer() {
        return ardUseNumer;
    }

    public void setArdUseNumer(String ardUseNumer) {
        this.ardUseNumer = ardUseNumer;
    }

    public String getElectriHoleNumer() {
        return electriHoleNumer;
    }

    public void setElectriHoleNumer(String electriHoleNumer) {
        this.electriHoleNumer = electriHoleNumer;
    }

    public String getRemaNumber() {
        return remaNumber;
    }

    public void setRemaNumber(String remaNumber) {
        this.remaNumber = remaNumber;
    }

    public String getRoadUtili() {
        return roadUtili;
    }

    public void setRoadUtili(String roadUtili) {
        this.roadUtili = roadUtili;
    }

    public String getResLength() {
        return resLength;
    }

    public void setResLength(String resLength) {
        this.resLength = resLength;
    }

    public String getNote() {
        return note;
    }

    public void setNote(String note) {
        this.note = note;
    }

    public boolean isFenZhiLineChecked() {
        return fenZhiLineChecked;
    }

    public void setEquipmentList(List<Equipment> equipmentList) {
        this.equipmentList = equipmentList;
    }

    public void setLayList(List<Lay> layList) {
        this.layList = layList;
    }

    public void setPointList(List<Point> pointList) {
        this.pointList = pointList;
    }

    public DaoSession getDaoSession() {
        return daoSession;
    }

    public void setDaoSession(DaoSession daoSession) {
        this.daoSession = daoSession;
    }

    public LineDao getMyDao() {
        return myDao;
    }

    public void setMyDao(LineDao myDao) {
        this.myDao = myDao;
    }

    public static Creator<Line> getCREATOR() {
        return CREATOR;
    }
//endregion

    //线的类别
    private String category;

    //线的类别
    private String type;

    //线的类型ID
    private String typeId;

    //线的类型
    private String types;

    //线路信息敷设方式通道状态[新建,拆除,整改.....] versionName
    private String pipe_laying_state;

    //线路状态[新建,拆除,整改.....] state
    private String state;

    //线路回数
    private String backNum;

    //线路根数
    private String num;

    //敷设方式名称
    private String methodName;

    //两点之间的距离
    private String length;

    //线的长度
    private String line_len;

    //项目id
    private Long item_id;

    //点A的经度
    private String latA;

    //点B的经度
    private String latB;

    //点A的纬度
    private String lonA;

    //点B的纬度
    private String lonB;
    //点A的名字
    private int name_a;//[用处不大]

    //点B的名字
    private int name_b;//[用处不大]
    //同杆并架
    private String parallelPole;
    //is那就是T分支路线="1", 十字街="2" 主线路  ""
    private String isT;
    private String path;
    //去module查询的id
    private String moduleID = "";

    //保存时候储存的信息
    private String moduleTxt = "";

    //外部数据库中存储的key
    private String legendTypeKey;
    //选择线是从那根线基础上分支出来的。
    private String fenZhiLineId;
    private boolean fenZhiLineChecked;
    //线中的设备
    @ToMany(referencedJoinProperty = "lineId")
    private List<Equipment> equipmentList;
    //线上的敷设方式
    @ToMany(referencedJoinProperty = "lineId")
    private List<Lay>layList;

    //线上的点
    @ToMany
    @JoinEntity(entity = PointAndLineBean.class, sourceProperty = "lineId", targetProperty = "pointId")
    private List<Point> pointList;

    /** Used to resolve relations */
    @Generated(hash = 2040040024)
    private transient DaoSession daoSession;

    /** Used for active entity operations. */
    @Generated(hash = 447887085)
    private transient LineDao myDao;

    @Generated(hash = 1807181889)
    public Line(Long id, String lineId, String cid, String start_id, String end_id, Long projectId,
            String name, String roadPands, String roadAdress, String resType, String resSpec,
            String dlzjSpec, String ardUseNumer, String electriHoleNumer, String remaNumber,
            String roadUtili, String resLength, String note, String srcYear, String category,
            String type, String typeId, String types, String pipe_laying_state, String state,
            String backNum, String num, String methodName, String length, String line_len, Long item_id,
            String latA, String latB, String lonA, String lonB, int name_a, int name_b,
            String parallelPole, String isT, String path, String moduleID, String moduleTxt,
            String legendTypeKey, String fenZhiLineId, boolean fenZhiLineChecked) {
        this.id = id;
        this.lineId = lineId;
        this.cid = cid;
        this.start_id = start_id;
        this.end_id = end_id;
        this.projectId = projectId;
        this.name = name;
        this.roadPands = roadPands;
        this.roadAdress = roadAdress;
        this.resType = resType;
        this.resSpec = resSpec;
        this.dlzjSpec = dlzjSpec;
        this.ardUseNumer = ardUseNumer;
        this.electriHoleNumer = electriHoleNumer;
        this.remaNumber = remaNumber;
        this.roadUtili = roadUtili;
        this.resLength = resLength;
        this.note = note;
        this.srcYear = srcYear;
        this.category = category;
        this.type = type;
        this.typeId = typeId;
        this.types = types;
        this.pipe_laying_state = pipe_laying_state;
        this.state = state;
        this.backNum = backNum;
        this.num = num;
        this.methodName = methodName;
        this.length = length;
        this.line_len = line_len;
        this.item_id = item_id;
        this.latA = latA;
        this.latB = latB;
        this.lonA = lonA;
        this.lonB = lonB;
        this.name_a = name_a;
        this.name_b = name_b;
        this.parallelPole = parallelPole;
        this.isT = isT;
        this.path = path;
        this.moduleID = moduleID;
        this.moduleTxt = moduleTxt;
        this.legendTypeKey = legendTypeKey;
        this.fenZhiLineId = fenZhiLineId;
        this.fenZhiLineChecked = fenZhiLineChecked;
    }

    @Generated(hash = 1133511183)
    public Line() {
    }

    public Long getId() {
        return this.id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getLineId() {
        return this.lineId;
    }

    public void setLineId(String lineId) {
        this.lineId = lineId;
    }

    public Long getProjectId() {
        return this.projectId;
    }

    public void setProjectId(Long projectId) {
        this.projectId = projectId;
    }

    public String getName() {
        return this.name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getCategory() {
        return this.category;
    }

    public void setCategory(String category) {
        this.category = category;
    }

    public String getType() {
        return this.type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getBackNum() {
        return this.backNum;
    }

    public void setBackNum(String backNum) {
        this.backNum = backNum;
    }

    public String getNum() {
        return this.num;
    }

    public void setNum(String num) {
        this.num = num;
    }

    public String getMethodName() {
        return this.methodName;
    }

    public void setMethodName(String methodName) {
        this.methodName = methodName;
    }

    public String getLength() {
        return this.length;
    }

    public void setLength(String length) {
        this.length = length;
    }

    public String getLine_len() {
        return this.line_len;
    }

    public void setLine_len(String line_len) {
        this.line_len = line_len;
    }

    public String getParallelPole() {
        return this.parallelPole;
    }

    public void setParallelPole(String parallelPole) {
        this.parallelPole = parallelPole;
    }

    public String getModuleID() {
        return this.moduleID;
    }

    public void setModuleID(String moduleID) {
        this.moduleID = moduleID;
    }

    public String getModuleTxt() {
        return this.moduleTxt;
    }

    public void setModuleTxt(String moduleTxt) {
        this.moduleTxt = moduleTxt;
    }

    public String getLegendTypeKey() {
        return this.legendTypeKey;
    }

    public void setLegendTypeKey(String legendTypeKey) {
        this.legendTypeKey = legendTypeKey;
    }

    /**
     * To-many relationship, resolved on first access (and after reset).
     * Changes to to-many relations are not persisted, make changes to the target entity.
     */
    @Generated(hash = 1376868807)
    public List<Equipment> getEquipmentList() {
        if (equipmentList == null) {
            final DaoSession daoSession = this.daoSession;
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            EquipmentDao targetDao = daoSession.getEquipmentDao();
            List<Equipment> equipmentListNew = targetDao._queryLine_EquipmentList(id);
            synchronized (this) {
                if (equipmentList == null) {
                    equipmentList = equipmentListNew;
                }
            }
        }
        return equipmentList;
    }

    @NonNull
    @Override
    public String toString() {
        return this.name;
    }

    public String toString1() {
        return "Line{" +
                "id=" + id +
                ", lineId='" + lineId + '\'' +
                ", cid='" + cid + '\'' +
                ", start_id='" + start_id + '\'' +
                ", end_id='" + end_id + '\'' +
                ", projectId=" + projectId +
                ", name='" + name + '\'' +
                ", category='" + category + '\'' +
                ", type='" + type + '\'' +
                ", typeId='" + typeId + '\'' +
                ", types='" + types + '\'' +
                ", pipe_laying_state='" + pipe_laying_state + '\'' +
                ", state='" + state + '\'' +
                ", backNum='" + backNum + '\'' +
                ", num='" + num + '\'' +
                ", methodName='" + methodName + '\'' +
                ", length='" + length + '\'' +
                ", line_len='" + line_len + '\'' +
                ", item_id=" + item_id +
                ", latA='" + latA + '\'' +
                ", latB='" + latB + '\'' +
                ", lonA='" + lonA + '\'' +
                ", lonB='" + lonB + '\'' +
                ", name_a=" + name_a +
                ", name_b=" + name_b +
                ", parallelPole='" + parallelPole + '\'' +
                ", isT='" + isT + '\'' +
                ", path='" + path + '\'' +
                ", moduleID='" + moduleID + '\'' +
                ", moduleTxt='" + moduleTxt + '\'' +
                ", legendTypeKey='" + legendTypeKey + '\'' +
                ", fenZhiLineId='" + fenZhiLineId + '\'' +
                ", fenZhiLineChecked=" + fenZhiLineChecked +
                ", equipmentList=" + equipmentList +
                ", pointList=" + pointList +
                ", daoSession=" + daoSession +
                ", myDao=" + myDao +
                '}';
    }

    /** Resets a to-many relationship, making the next get call to query for a fresh result. */
    @Generated(hash = 1882233752)
    public synchronized void resetEquipmentList() {
        equipmentList = null;
    }

    /**
     * To-many relationship, resolved on first access (and after reset).
     * Changes to to-many relations are not persisted, make changes to the target entity.
     */
    @Generated(hash = 1123203942)
    public List<Point> getPointList() {
        if (pointList == null) {
            final DaoSession daoSession = this.daoSession;
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            PointDao targetDao = daoSession.getPointDao();
            List<Point> pointListNew = targetDao._queryLine_PointList(id);
            synchronized (this) {
                if (pointList == null) {
                    pointList = pointListNew;
                }
            }
        }
        return pointList;
    }

    /** Resets a to-many relationship, making the next get call to query for a fresh result. */
    @Generated(hash = 18518400)
    public synchronized void resetPointList() {
        pointList = null;
    }

    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#delete(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 128553479)
    public void delete() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.delete(this);
    }

    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#refresh(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 1942392019)
    public void refresh() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.refresh(this);
    }

    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#update(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 713229351)
    public void update() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.update(this);
    }

    public String getTypeId() {
        return this.typeId;
    }

    public void setTypeId(String typeId) {
        this.typeId = typeId;
    }

    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 360158775)
    public void __setDaoSession(DaoSession daoSession) {
        this.daoSession = daoSession;
        myDao = daoSession != null ? daoSession.getLineDao() : null;
    }

    public String getCid() {
        return this.cid;
    }

    public void setCid(String cid) {
        this.cid = cid;
    }

    public String getStart_id() {
        return this.start_id;
    }

    public void setStart_id(String start_id) {
        this.start_id = start_id;
    }

    public String getEnd_id() {
        return this.end_id;
    }

    public void setEnd_id(String end_id) {
        this.end_id = end_id;
    }

    public String getTypes() {
        return this.types;
    }

    public void setTypes(String types) {
        this.types = types;
    }

    public String getPipe_laying_state() {
        return this.pipe_laying_state;
    }

    public void setPipe_laying_state(String pipe_laying_state) {
        this.pipe_laying_state = pipe_laying_state;
    }

    public String getState() {
        return this.state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public Long getItem_id() {
        return this.item_id;
    }

    public void setItem_id(Long item_id) {
        this.item_id = item_id;
    }

    public String getLatA() {
        return this.latA;
    }

    public void setLatA(String latA) {
        this.latA = latA;
    }

    public String getLatB() {
        return this.latB;
    }

    public void setLatB(String latB) {
        this.latB = latB;
    }

    public String getLonA() {
        return this.lonA;
    }

    public void setLonA(String lonA) {
        this.lonA = lonA;
    }

    public String getLonB() {
        return this.lonB;
    }

    public void setLonB(String lonB) {
        this.lonB = lonB;
    }

    public int getName_a() {
        return this.name_a;
    }

    public void setName_a(int name_a) {
        this.name_a = name_a;
    }

    public int getName_b() {
        return this.name_b;
    }

    public void setName_b(int name_b) {
        this.name_b = name_b;
    }

    public String getIsT() {
        return this.isT;
    }

    public void setIsT(String isT) {
        this.isT = isT;
    }

    public String getPath() {
        return this.path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public String getFenZhiLineId() {
        return this.fenZhiLineId;
    }

    public void setFenZhiLineId(String fenZhiLineId) {
        this.fenZhiLineId = fenZhiLineId;
    }

    public boolean getFenZhiLineChecked() {
        return this.fenZhiLineChecked;
    }

    public void setFenZhiLineChecked(boolean fenZhiLineChecked) {
        this.fenZhiLineChecked = fenZhiLineChecked;
    }
    public String getDlzjSpec() {
        return dlzjSpec;
    }

    public void setDlzjSpec(String dlzjSpec) {
        this.dlzjSpec = dlzjSpec;
    }
    /**
     * To-many relationship, resolved on first access (and after reset).
     * Changes to to-many relations are not persisted, make changes to the target entity.
     */
    @Generated(hash = 297945155)
    public List<Lay> getLayList() {
        if (layList == null) {
            final DaoSession daoSession = this.daoSession;
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            LayDao targetDao = daoSession.getLayDao();
            List<Lay> layListNew = targetDao._queryLine_LayList(id);
            synchronized (this) {
                if (layList == null) {
                    layList = layListNew;
                }
            }
        }
        return layList;
    }

    /** Resets a to-many relationship, making the next get call to query for a fresh result. */
    @Generated(hash = 1349491039)
    public synchronized void resetLayList() {
        layList = null;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeValue(this.id);
        dest.writeString(this.lineId);
        dest.writeString(this.cid);
        dest.writeString(this.start_id);
        dest.writeString(this.end_id);
        dest.writeValue(this.projectId);
        dest.writeString(this.name);
        dest.writeString(this.roadPands);
        dest.writeString(this.roadAdress);
        dest.writeString(this.resType);
        dest.writeString(this.resSpec);
        dest.writeString(this.dlzjSpec);
        dest.writeString(this.ardUseNumer);
        dest.writeString(this.electriHoleNumer);
        dest.writeString(this.remaNumber);
        dest.writeString(this.roadUtili);
        dest.writeString(this.resLength);
        dest.writeString(this.note);
        dest.writeString(this.srcYear);
        dest.writeString(this.category);
        dest.writeString(this.type);
        dest.writeString(this.typeId);
        dest.writeString(this.types);
        dest.writeString(this.pipe_laying_state);
        dest.writeString(this.state);
        dest.writeString(this.backNum);
        dest.writeString(this.num);
        dest.writeString(this.methodName);
        dest.writeString(this.length);
        dest.writeString(this.line_len);
        dest.writeValue(this.item_id);
        dest.writeString(this.latA);
        dest.writeString(this.latB);
        dest.writeString(this.lonA);
        dest.writeString(this.lonB);
        dest.writeInt(this.name_a);
        dest.writeInt(this.name_b);
        dest.writeString(this.parallelPole);
        dest.writeString(this.isT);
        dest.writeString(this.path);
        dest.writeString(this.moduleID);
        dest.writeString(this.moduleTxt);
        dest.writeString(this.legendTypeKey);
        dest.writeString(this.fenZhiLineId);
        dest.writeByte(this.fenZhiLineChecked ? (byte) 1 : (byte) 0);
        dest.writeTypedList(this.equipmentList);
        dest.writeTypedList(this.layList);
        dest.writeTypedList(this.pointList);
    }

    protected Line(Parcel in) {
        this.id = (Long) in.readValue(Long.class.getClassLoader());
        this.lineId = in.readString();
        this.cid = in.readString();
        this.start_id = in.readString();
        this.end_id = in.readString();
        this.projectId = (Long) in.readValue(Long.class.getClassLoader());
        this.name = in.readString();
        this.roadPands = in.readString();
        this.roadAdress = in.readString();
        this.resType = in.readString();
        this.resSpec = in.readString();
        this.dlzjSpec = in.readString();
        this.ardUseNumer = in.readString();
        this.electriHoleNumer = in.readString();
        this.remaNumber = in.readString();
        this.roadUtili = in.readString();
        this.resLength = in.readString();
        this.note = in.readString();
        this.srcYear = in.readString();
        this.category = in.readString();
        this.type = in.readString();
        this.typeId = in.readString();
        this.types = in.readString();
        this.pipe_laying_state = in.readString();
        this.state = in.readString();
        this.backNum = in.readString();
        this.num = in.readString();
        this.methodName = in.readString();
        this.length = in.readString();
        this.line_len = in.readString();
        this.item_id = (Long) in.readValue(Long.class.getClassLoader());
        this.latA = in.readString();
        this.latB = in.readString();
        this.lonA = in.readString();
        this.lonB = in.readString();
        this.name_a = in.readInt();
        this.name_b = in.readInt();
        this.parallelPole = in.readString();
        this.isT = in.readString();
        this.path = in.readString();
        this.moduleID = in.readString();
        this.moduleTxt = in.readString();
        this.legendTypeKey = in.readString();
        this.fenZhiLineId = in.readString();
        this.fenZhiLineChecked = in.readByte() != 0;
        this.equipmentList = in.createTypedArrayList(Equipment.CREATOR);
        this.layList = in.createTypedArrayList(Lay.CREATOR);
        this.pointList = in.createTypedArrayList(Point.CREATOR);
    }

    public static final Creator<Line> CREATOR = new Creator<Line>() {
        @Override
        public Line createFromParcel(Parcel source) {
            return new Line(source);
        }

        @Override
        public Line[] newArray(int size) {
            return new Line[size];
        }
    };
}
